package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.SysPurchaseApply;
import com.ruoyi.system.domain.SysPurchaseApplyFile;
import com.ruoyi.system.mapper.SysPurchaseApplyMapper;
import com.ruoyi.system.service.ISysPurchaseApplyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class SysPurchaseApplyServiceImpl implements ISysPurchaseApplyService {

    @Resource
    private SysPurchaseApplyMapper sysPurchaseApplyMapper;

    @Override
    public int insertSysPurchaseApply(SysPurchaseApply sysPurchaseApply) {
        sysPurchaseApply.setApplyState(0);
        sysPurchaseApply.setIsdelFlag(0);
        return sysPurchaseApplyMapper.insertSysPurchaseApply(sysPurchaseApply);
    }

    @Override
    public List<SysPurchaseApply> selectSysPurchaseApplyByPurId(Long deviceId) {
        return sysPurchaseApplyMapper.selectSysPurchaseApplyByPurIds(deviceId);
    }

    @Override
    public Long insertPathNames(SysPurchaseApplyFile sysPurchaseApply) {
        Date date = new Date();
        sysPurchaseApply.setUploadTime(date);
        sysPurchaseApplyMapper.insertPathName(sysPurchaseApply);
        Long fileId = sysPurchaseApply.getFileId();
        return fileId;
    }

    @Override
    public int updateYesState(Long purId) {

        return sysPurchaseApplyMapper.updateYesState(purId);
    }

    @Override
    public int updateSysPurchaseApply(SysPurchaseApply sysPurchaseApply) {
        return sysPurchaseApplyMapper.updateSysPurchaseApply(sysPurchaseApply);
    }

    @Override
    public int deleteSysPurchaseApplyById(Long purId) {
        return sysPurchaseApplyMapper.deleteSysPurchaseApplyById(purId);
    }
}
